<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" style="background-color: #fff;">
    <input type="hidden" name="row[id]" value="{$row.id}">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('录入时间')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
           {$row.date}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('录入人')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            {$row.user_name}
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('类别')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            {$row.type}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人类型')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            {$row.ld_type}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人姓名')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            {$row.name}
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人电话')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            {$row.phone}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('车型')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            {$row.chexing}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('备注')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            {$row.content}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('催办内容')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            {$row.cuiban_beizhu}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('催办图片')}:</label>
        <div class="col-xs-12 col-sm-8">
            <?php foreach($row['cuiban_img'] as $k => $v){?>
            <img src="{$v}" data-magnify="gallery" data-src="{$v}" width="100px">
            <?php }?>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('检索信息')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" data-source="script/buchang/index" class="form-control selectpage" type="text" value="" data-field="title" data-search-field="title"data-pagination="true" data-page-size="10"  >
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('回复信息')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-buchang_beizhu" class="form-control" name="row[buchang_beizhu]" type="text">{$row.buchang_beizhu}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label for="c-buchang_img" class="control-label col-xs-12 col-sm-2">{:__('回复图片')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-buchang_img" class="form-control" size="50" name="row[buchang_img]" type="text"
                       value="{$row.buchang_img|htmlentities}">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-buchang_img" class="btn btn-danger faupload"
                                  data-input-id="c-buchang_img"
                                  data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp"
                                  data-multiple="false" data-preview-id="p-buchang_img"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-buchang_img" class="btn btn-primary fachoose"
                                  data-input-id="c-buchang_img" data-mimetype="image/*" data-multiple="false"><i
                            class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-buchang_img"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-buchang_img"></ul>
        </div>
    </div>

    <div class="form-group" style="margin-top: 50px;padding-bottom: 50px;margin-left: 150px;">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 " style="margin: auto;">
            <button type="button" class="btn btn-primary btn-embossed " style="margin-left: 10px;" onclick="zuihou_save()">{:__('保存并关闭')}</button>
        </div>
    </div>
</form>

<script src="/assets/libs/jquery/dist/jquery.js"></script>
<script>
    function zuihou_save() {
        var formData = $("#add-form").serialize();
        $.ajax({
            url: "{:url('baoan/beizhu/save_list')}",
            data: formData,
            type: 'post',
            dataType: 'json',
            success: function (ret) {
                if (ret.code == 1) {
                    var res = ret.data
                    $('#buchang_beizhu_'+res.id, window.parent.document).html(res.buchang_beizhu);
                    $('#buchang_date_'+res.id, window.parent.document).html(res.buchang_date);
                    var html = '';
                    var i = 0;
                    for (i = 0;i<res.buchang_img.length;i++){
                        html += `<img src="`+res.buchang_img[i]+`"  data-magnify="gallery" data-src="`+res.buchang_img[i]+`" style="max-width: 100px;">`;
                    }
                    $('#buchang_img_'+res.id, window.parent.document).html(html);
                    layer.msg('保存成功！', {
                        time: 1000,
                        icon: 1
                    }, function (index) {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //执行关闭
                    })
                } else {
                    layer.alert(res.msg)
                }
            }
        })
    }

</script>